
const jwt = require('jsonwebtoken');
// PRIVATE_KEY PUBLIC_KEY
const { PRIVATE_KEY } = require('../app/config')


class AuthController {
    async login(ctx, next) {
        const { id, name } = ctx.user;
        const token = jwt.sign({ id, name }, PRIVATE_KEY, {
            expiresIn: 60 * 60 * 24,
            algorithm: 'RS256'
        })
        ctx.body = {
            code: 0,
            message: '',
            data: {
                id, name, token
            }
        }
    }
}

module.exports = new AuthController()